feat(completion): complete session aliases and config keys#303
Merged
Conversation
Shell completion only offered static tokens before: command names, flags, shell names, and config subcommands. The values you actually reach for, session aliases for `dispatch open` and config keys for `dispatch config get`/`set`/`unset`, still had to be typed by hand. Add a hidden `dispatch __complete <kind>` command that prints newline-separated candidates for a kind (aliases, config-keys, shells) and wire the bash, zsh, fish, and PowerShell scripts to call it at the right argument positions. Aliases read local config and config keys come from the settable field list, so each lookup stays fast. Unknown kinds print nothing and exit zero so a completer never breaks, and the command is left out of help and usage. Closes #298 Co-authored-by: Copilot App <[email protected]>
# Conflicts: # cmd/dispatch/cli.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds dynamic values to shell completion so
openaliases and config keys complete without typing.What changed
dispatch __complete <kind>command that prints newline-separated candidates for a kind. Supported kinds:aliases(configured session aliases),config-keys(settable config keys), andshells(the supported completion shells).__completeat the right positions:dispatch open <TAB>completes session aliases.dispatch config get <TAB>(andset/unset) completes config keys.dispatch completion <TAB>completes the shells, now sourced from__complete.__completecommand is left out of help and usage.Tests
runCompleteunit tests: config-keys count and membership, sorted aliases, empty aliases, silent behavior on config load error, shells output, unknown kind, and no kind.handleArgs __completereturns done with no error, and a test asserts help output does not advertise__complete.go build,go vet,go test ./..., golangci-lint (0 issues), and deadcode all pass.Closes #298